<template>
  <div>
    <el-card shadow="never" class="d2-mb titleline">
      <template slot="header" style="height:66px;">
        <span class="title_x el-button--primary fl"></span>
        <p class="title_l fl">子账户结算单查询</p>
      </template>
      <el-card shadow="never" class="d2-mb">
        <el-form class="demo-form-inline" :rules="rules" ref="capForm" :model="capForm" label-width="100px">
           <el-row :gutter="20">
           <el-col :span="9">
                 <el-form-item label="交易日期">
                <el-col :span="11">
                   <el-form-item prop="start_date">
                  <el-date-picker type="date" :picker-options="cappickerOptionsStart" v-model="capForm.start_date" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
                   </el-form-item>
                </el-col>
                <el-col class="line tc" :span="2">~</el-col>
                <el-col :span="11">
                   <el-form-item prop="end_date">
                  <el-date-picker type="date" :picker-options="cappickerOptionsEnd" v-model="capForm.end_date" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
                   </el-form-item>
                </el-col>
              </el-form-item>
            </el-col>
           <el-col :span="5">
           <el-form-item label="子账号">
            <el-select v-model="capForm.realaccountcode" placeholder="请选择筛选条件" filterable>
                <el-option v-for="item in realaccountList" :key="item.realaccountcode" :label="item.realaccountname"
                           :value="item.realaccountcode">
                  <span style="float: left">{{item.realaccountname}}</span>
                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.realaccountcode}}</span>
                </el-option>
              </el-select>
          </el-form-item>
          </el-col>
          <el-col :span="2">
          <el-form-item>
            <el-button size="mini" type="primary" @click="handle_realaccouncap('capForm')">查询</el-button>
          </el-form-item>
          </el-col>
          </el-row>
        </el-form>
      </el-card>
    </el-card>
    <!-- 资金状况 -->
    <el-card shadow="never" class="d2-mb titleline">
      <template slot="header" style="height:66px;">
        <span class="title_x el-button--primary fl"></span>
        <p class="title_l fl">资金状况</p>
      </template>
      <el-row class="f14 mt20 " style="line-height:30px;">
          <el-col :span="7" :offset="1">
            期初结存 Balance b/f：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.BalanceBF }}
          </el-col>
          <el-col :span="7" :offset="1">
            期末结存 Balance c/f：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.BalanceCF }}
          </el-col>
          <el-col :span="7" :offset="1">
            持仓盯市盈亏 MTM P/L：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.dPositionProfit }}
          </el-col>
          <el-col :span="7" :offset="1">
            客户权益 Client Equity：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.ClientEquity }}
          </el-col>
          <el-col :span="7" :offset="1">
            保证金占用 Margin Occupied：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.dCurrMargin }}
          </el-col>
          <el-col :span="7" :offset="1">
            可用资金 Fund Avail：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.dAvailable }}
          </el-col>
          <el-col :span="7" :offset="1">
            基础保证金 Initial Margin：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.InitialMargin }}
          </el-col>
          <el-col :span="7" :offset="1">
            出 入 金 Deposit/Withdrawal：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.DepositAndWithdrawal }}
          </el-col>
          <el-col :span="7" :offset="1">
            平仓盈亏 Realized P/L：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.dCloseProfit }}
          </el-col>
          <el-col :span="7" :offset="1">
            质 押 金 Pledge Amount：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.PledgeAmount }}
          </el-col>
          <el-col :span="7" :offset="1">
            期权执行盈亏 Exercise P/L：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.Exercise_PL }}
          </el-col>
          <el-col :span="7" :offset="1">
            货币质押保证金占用 FX Pledge Occ.：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.FXPledgeOcc }}
          </el-col>
          <el-col :span="7" :offset="1">
            手 续 费 Commission：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.dCommission }}
          </el-col>
          <el-col :span="7" :offset="1">
            行权手续费 Exercise Fee：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.ExerciseFee }}
          </el-col>
          <el-col :span="7" :offset="1">
            交割保证金 Delivery Margin：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.DeliveryMargin }}
          </el-col>
          <el-col :span="7" :offset="1">
            交割手续费 Delivery Fee：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.DeliveryFee }}
          </el-col>
          <el-col :span="7" :offset="1">
            多头期权市值 Market value(long)：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.MarketValueLong }}
          </el-col>
          <el-col :span="7" :offset="1">
            货币质入 New FX Pledge：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.NewFXPledge }}
          </el-col>
          <el-col :span="7" :offset="1">
            空头期权市值 Market value(short)：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.MarketValueShort }}
          </el-col>
          <el-col :span="7" :offset="1">
            货币质出 FX Redemption：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.FXRedemption }}
          </el-col>
          <el-col :span="7" :offset="1">
            市值权益 Market value(equity)：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.MarketValueEquity }}
          </el-col>
          <el-col :span="7" :offset="1">
            质押变化金额 Chg in Pledge Amt：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.ChgInPledgeAmt }}
          </el-col>
          <el-col :span="7" :offset="1">
            权利金收入 Premium received：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.PremiumReceived }}
          </el-col>
          <el-col :span="7" :offset="1">
            风 险 度 Risk Degree：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.RiskDegree }}
          </el-col>
          <el-col :span="7" :offset="1">
            权利金支出 Premium paid：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.PremiumPaid }}
          </el-col>
          <el-col :span="7" :offset="1">
            应追加资金 Margin Call：
          </el-col>
          <el-col :span="3">
            {{ statementsList_zj.MarginCall }}
          </el-col>
        </el-row>
    </el-card>
    <!-- 出入金明细 -->
    <el-card shadow="never" class="d2-mb titleline">
      <template slot="header" style="height:66px;">
        <span class="title_x el-button--primary fl"></span>
        <p class="title_l fl">出入金明细</p>
      </template>
      <el-table
                id="table_excel2"
                ref="singleTable"
                :data="statementsList_crj"
                highlight-current-row
                border
                show-summary
                :summary-method="getSummaries_crj"
                fit
                style="width:100%;margin:20px 0;">
          <el-table-column
                  label="交易日期"
                  prop="tradingday"
                  sortable>
          </el-table-column>
          <el-table-column
                  label="方向"
                  prop="BusinessName"
                  sortable>
          </el-table-column>
          <el-table-column
                  label="金额"
                  prop="total"
                  sortable>
          </el-table-column>
        </el-table>
    </el-card>
    <!--  成交记录 -->
    <el-card shadow="never" class="d2-mb titleline">
      <template slot="header" style="height:66px;">
        <span class="title_x el-button--primary fl"></span>
        <p class="title_l fl">成交记录</p>
      </template>
       <el-table
          id="table_excel3"
          ref="singleTable"
          :data="statementsList_cj"
          highlight-current-row
          border
          show-summary
          :summary-method="getSummaries_cj"
          fit
          style="width: 100%;margin:20px 0;">
          <el-table-column
            label="成交日期"
            prop="TradeDate" width="105"
            sortable>
          </el-table-column>
          <el-table-column
            label="交易所"
            prop="ExchangeName" width="90"
            sortable>
          </el-table-column>
          <el-table-column
            label="品种"
            prop="ProductName"
            sortable>
          </el-table-column>
          <el-table-column
            label="合约"
            prop="InstrumentID"
            sortable>
          </el-table-column>
          <el-table-column
            label="买/卖"
            prop="DirectionName"
            sortable>
          </el-table-column>
            <el-table-column
                    label="投/保"
                    prop="HedgeFlagName"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="成交价"
                    prop="Price" width="90"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="手数"
                    prop="Volume"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="成交额" width="90"
                    prop="tradedamount"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="开平"
                    prop="OffsetFlagName"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="手续费"
                    prop="commission" width="90"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="平仓盈亏"
                    prop="CloseProfit" width="105"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="权利金收支" width="120"
                    prop="Premium_received"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="成交序号" width="105"
                    prop="TradeID"
                    sortable>
            </el-table-column>
        </el-table>
    </el-card>
    <!-- 平仓明细 -->
    <el-card shadow="never" class="d2-mb titleline">
      <template slot="header" style="height:66px;">
        <span class="title_x el-button--primary fl"></span>
        <p class="title_l fl">平仓明细</p>
      </template>
     <el-table
          id="table_excel4"
          ref="singleTable"
          :data="statementsList_pc"
          highlight-current-row
          border
          show-summary
          :summary-method="getSummaries_pc"
          fit
          style="width: 100%;margin:20px 0;">
          <el-table-column
            label="平仓日期"
            prop="CloseDate"
             width="105"
            sortable>
          </el-table-column>
            <el-table-column
                    label="交易所"
                    prop="ExchangeName" width="90"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="品种"
                    prop="ProductName"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="合约"
                    prop="InstrumentID"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="开仓日期" width="105"
                    prop="OpenDate"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="买/卖"
                    prop="DirectionName"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="手数"
                    prop="Volume"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="开仓价" width="90"
                    prop="OpenPrice"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="昨结算" width="90"
                    prop="PreSettlementPrice"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="成交价" width="90"
                    prop="Price"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="平仓盈亏"
                    prop="CloseProfit" width="105"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="权利金收支" width="115"
                    prop="Premium_received"
                    sortable>
            </el-table-column>
        </el-table>
    </el-card>
    <!-- 持仓明细 -->
    <el-card shadow="never" class="d2-mb titleline">
      <template slot="header" style="height:66px;">
        <span class="title_x el-button--primary fl"></span>
        <p class="title_l fl">持仓明细</p>
      </template>
      <el-table
          id="table_excel5"
          ref="singleTable"
          :data="statementsList_cc"
          highlight-current-row
          border
          show-summary
          :summary-method="getSummaries_cc"
          fit
          style="width: 100%;margin:20px 0;">
            <el-table-column
                    label="交易所" width="90"
                    prop="ExchangeName"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="品种"
                    prop="ProductName"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="合约"
                    prop="InstrumentID"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="开仓日期" width="105"
                    prop="OpenDate"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="投/保"
                    prop="HedgeFlagName"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="买/卖"
                    prop="DirectionName"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="持仓量" width="90"
                    prop="Volume"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="开仓价" width="90"
                    prop="OpenPrice"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="昨结算" width="90"
                    prop="LastSettlementPrice"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="结算价" width="90"
                    prop="SettlementPrice"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="浮动盈亏"
                    prop="float_profit_loss" width="105"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="盯市盈亏" width="105"
                    prop="mark_profit_loss"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="保证金" width="90"
                    prop="Margin"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="期权市值" width="105"
                    prop="Market_value"
                    sortable>
            </el-table-column>
        </el-table>
    </el-card>
    <!-- 持仓汇总 -->
    <el-card shadow="never" class="d2-mb titleline">
      <template slot="header" style="height:66px;">
        <span class="title_x el-button--primary fl"></span>
        <p class="title_l fl">持仓汇总</p>
      </template>
     <el-table
          id="table_excel6"
          ref="singleTable"
          :data="statementsList_ccz"
          highlight-current-row
          border
          show-summary
          :summary-method="getSummaries_ccz"
          fit
          style="width: 100%;margin:20px 0;">
            <el-table-column
                    label="品种"
                    prop="ProductName"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="合约"
                    prop="InstrumentID"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="买持"
                    prop="LongPos"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="买均价"
                    prop="AvgBuyPrice" width="90"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="卖持"
                    prop="ShortPos"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="卖均价"
                    prop="AvgSellPrice" width="90"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="昨结算"
                    prop="PreSettlementPrice" width="90"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="今结算"
                    prop="SettlementPrice" width="90"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="持仓盯市盈亏" width="130"
                    prop="PositionProfit"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="保证金占用" width="115"
                    prop="UseMargin"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="投/保"
                    prop="HedgeFlagName"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="多头期权市值" width="130"
                    prop="MarketValueLong"
                    sortable>
            </el-table-column>
            <el-table-column
                    label="空头期权市值" width="130"
                    prop="MarketValueShort"
                    sortable>
            </el-table-column>
        </el-table>
    </el-card>
  </div>
</template>
<script>

import { conreturnaccount, conlogiccap, conlogicinout, conlogictrade, conlogicclose, conlogicpos, concustomer, conlogicposall } from '../../../../../api/url_lcc';
export default {
  data() {
    return {
      // 资金
      realaccountList:[],
      statementsList_zj:[],
      statementsList_cj:[],
      statementsList_pc:[],
      statementsList_cc:[],
      statementsList_ccz:[],
      statementsList_crj:[],
      customerList:[],
      captableData: [],
      statementsList_crj:[],
      capForm:{
        page: 1, //当前页
        pageSize: 20,
        totalPage: 1,
        logic_account:"",
        start_date:"",
        end_date:"",
      },
      // 成交
      tradedableData:[],
      tradedForm:{
        page: 1, //当前页
        pageSize: 20,
        totalPage: 1,
        logic_account:"",
        start_date:"",
        end_date:"",
      },
      // 持仓
      postableData:[],
      posForm:{
        page: 1, //当前页
        pageSize: 20,
        totalPage: 1,
        logic_account:"",
        start_date:"",
        end_date:"",
      },

           // ///////////////////////////////时间限制
       cappickerOptionsStart: {
          disabledDate: time => {
            let endDateVal = this.capForm.end_date;
            if (endDateVal) {
              return time.getTime() > new Date(endDateVal).getTime();
            }
          }
        },
       cappickerOptionsEnd: {
          disabledDate: time => {
            let beginDateVal = this.capForm.start_date;
            if (beginDateVal) {
              return (
                time.getTime() <
                new Date(beginDateVal).getTime() - 1 * 24 * 60 * 60 * 1000
              );
            }
          }
        },
        tradedpickerOptionsStart: {
          disabledDate: time => {
            let endDateVal = this.tradedForm.end_date;
            if (endDateVal) {
              return time.getTime() > new Date(endDateVal).getTime();
            }
          }
        },
       tradedpickerOptionsEnd: {
          disabledDate: time => {
            let beginDateVal = this.tradedForm.start_date;
            if (beginDateVal) {
              return (
                time.getTime() <
                new Date(beginDateVal).getTime() - 1 * 24 * 60 * 60 * 1000
              );
            }
          }
        },
        pospickerOptionsStart: {
          disabledDate: time => {
            let endDateVal = this.posForm.end_date;
            if (endDateVal) {
              return time.getTime() > new Date(endDateVal).getTime();
            }
          }
        },
       pospickerOptionsEnd: {
          disabledDate: time => {
            let beginDateVal = this.posForm.start_date;
            if (beginDateVal) {
              return (
                time.getTime() <
                new Date(beginDateVal).getTime() - 1 * 24 * 60 * 60 * 1000
              );
            }
          }
        },
      // 限制
      rules: {
            start_date: [
              { type: 'string', required: true, message: '请选择交易起始日期', trigger: 'change' }
            ],
            end_date: [
              { type: 'string', required: true, message: '请选择交易结束日期', trigger: 'change' }
            ],
           
          },    
    }
  },
  methods: {
     // // // // // // // // // // // // // // // // // // // // // // // // // // // // 资金状况
      //  子账户
     handle_customerChange(){
         let params = {
           account_type:"logic"
        };
       conreturnaccount(params).then(res => {
          this.realaccountList = []
            var data = res.result
            for (var i = 0; i < data.length; i++) {
              this.realaccountList[i] = {
                  'realaccountcode': data[i].LogicAccountCode,
                  'realaccountname': data[i].LogicAccountName
              }
            }
           
         }).catch(err =>{
          this.$message.error(err.msg);
        });
    },
    handle_realaccouncap(capForm){
       const rule1 = new Promise((resolve, reject) => {
        this.$refs[capForm].validate(valid => {
          if (valid) {
            resolve();
          } else {
            console.log("error submit!!");
            return false;
          }
        });
      });
       Promise.all([rule1]).then(() => {
       this.statements_zj(),
       this.statements_crj(),
       this.statements_cj(),
       this.statements_pc(),
       this.statements_cc(),
       this.statements_ccz()
        })
    },
     statements_zj(){
          let params = {
              account: this.capForm.realaccountcode,
              start_date: this.capForm.start_date,
              end_date: this.capForm.end_date,
          };
          conlogiccap(params).then(res => {
             this.statementsList_zj = [];
             this.statementsList_zj = res.result[0]
          });
      },
    // // // // // // // // // // // // // // // // // // // // // // // // // // // // 出入金明细
     statements_crj(){
          let params = {
              account: this.capForm.realaccountcode,
              start_date: this.capForm.start_date,
              end_date: this.capForm.end_date,
          };
          conlogicinout(params).then(res => {
              this.statementsList_crj = []
              var data = res.result
              for (var i = 0; i < data.length; i++) {
                  this.statementsList_crj[i] = {
                      tradingday:data[i]['tradingday'],
                      BusinessName:data[i]['BusinessName'],
                      total:data[i]['total']
                  }

              }

          });
      },
    // // // // // // // // // // // // // // // // // // // // // // // // // // // // 成交明细
    statements_cj(){
          let params = {
               account: this.capForm.realaccountcode,
              start_date: this.capForm.start_date,
              end_date: this.capForm.end_date,
          };
          conlogictrade(params).then(res => {
              this.statementsList_cj = []
              var data = res.result
              for (var i = 0; i < data.length; i++) {
                  this.statementsList_cj[i] = {
                      TradeDate:data[i]['TradeDate'],
                      ProductID:data[i]['ProductID'],
                      ExchangeID:data[i]['ExchangeID'],
                      ExchangeName:data[i]['ExchangeName'],
                      ProductName:data[i]['ProductName'],
                      InstrumentID:data[i]['InstrumentID'],
                      DirectionName:data[i]['DirectionName'],
                      HedgeFlagName:data[i]['HedgeFlagName'],
                      Price:data[i]['Price'],
                      Volume:data[i]['Volume'],
                      tradedamount:data[i]['tradedamount'],
                      OffsetFlagName:data[i]['OffsetFlagName'],
                      commission:data[i]['commission'],
                      CloseProfit:data[i]['CloseProfit'],
                      Premium_received:data[i]['Premium_received'],
                      TradeID:data[i]['TradeID'],

                  }

              }
          });
      },
    // // // // // // // // // // // // // // // // // // // // // // // // // // // // 平仓明细
    statements_pc(){
          let params = {
              account: this.capForm.realaccountcode,
              start_date: this.capForm.start_date,
              end_date: this.capForm.end_date,
          };
          conlogicclose(params).then(res => {
              this.statementsList_pc = []
              var data = res.result
              for (var i = 0; i < data.length; i++) {
                  this.statementsList_pc[i] = {
                      CloseDate:data[i]['CloseDate'],
                      ProductID:data[i]['ProductID'],
                      ExchangeID:data[i]['ExchangeID'],
                      ExchangeName:data[i]['ExchangeName'],
                      ProductName:data[i]['ProductName'],
                      InstrumentID:data[i]['InstrumentID'],
                      OpenDate:data[i]['OpenDate'],
                      DirectionName:data[i]['DirectionName'],
                      Volume:data[i]['Volume'],
                      OpenPrice:data[i]['OpenPrice'],
                      PreSettlementPrice:data[i]['PreSettlementPrice'],
                      Price:data[i]['Price'],
                      CloseProfit:data[i]['CloseProfit'],
                      Premium_received:data[i]['Premium_received']
                  }

              }
          });
      },
    // // // // // // // // // // // // // // // // // // // // // // // // // // // // 持仓明细
     statements_cc(){
          let params = {
              account: this.capForm.realaccountcode,
              start_date: this.capForm.start_date,
              end_date: this.capForm.end_date,
          };
          conlogicpos(params).then(res => {
              this.statementsList_cc = []
              var data = res.result
              for (var i = 0; i < data.length; i++) {
                  this.statementsList_cc[i] = {
                      CurrMargin:data[i]['CurrMargin'],
                      ExchangeID:data[i]['ExchangeID'],
                      ExchangeName:data[i]['ExchangeName'],
                      ProductID:data[i]['ProductID'],
                      ProductName:data[i]['ProductName'],
                      InstrumentID:data[i]['InstrumentID'],
                      CloseDate:data[i]['CloseDate'],
                      HedgeFlagName:data[i]['HedgeFlagName'],
                      DirectionName:data[i]['DirectionName'],
                      Volume:data[i]['Volume'],
                      OpenPrice:data[i]['OpenPrice'],
                      LastSettlementPrice:data[i]['LastSettlementPrice'],
                      SettlementPrice:data[i]['SettlementPrice'],
                      float_profit_loss:data[i]['float_profit_loss'],
                      mark_profit_loss:data[i]['mark_profit_loss'],
                      Margin:data[i]['Margin'],
                      OpenDate:data[i]['OpenDate'],
                      Market_value:data[i]['Market_value']
                  }

              }
          });
      },
    // // // // // // // // // // // // // // // // // // // // // // // // // // // // 持仓汇总
    statements_ccz(){
          let params = {
              account: this.capForm.realaccountcode,
              start_date: this.capForm.start_date,
              end_date: this.capForm.end_date,
          };
          conlogicposall(params).then(res => {
              this.statementsList_ccz = []
              var data = res.result
              for (var i = 0; i < data.length; i++) {
                  this.statementsList_ccz[i] = {
                      CurrMargin:data[i]['CurrMargin'],
                      ProductName:data[i]['ProductName'],
                      ProductID:data[i]['ProductID'],
                      InstrumentID:data[i]['InstrumentID'],
                      LongPos:data[i]['LongPos'],
                      AvgBuyPrice:data[i]['AvgBuyPrice'],
                      ShortPos:data[i]['ShortPos'],
                      AvgSellPrice:data[i]['AvgSellPrice'],
                      PreSettlementPrice:data[i]['PreSettlementPrice'],
                      SettlementPrice:data[i]['SettlementPrice'],
                      PositionProfit:data[i]['PositionProfit'],
                      UseMargin:data[i]['UseMargin'],
                      HedgeFlagName:data[i]['HedgeFlagName'],
                      MarketValueLong:data[i]['MarketValueLong'],
                      MarketValueShort:data[i]['MarketValueShort']
                  }

              }
          });
      },

      //自定义合计---出入金
      getSummaries_crj(param) {
          const { columns, data } = param
          const sums = []
          columns.forEach((column, index) => {
              if (index === 0) {
                  sums[index] = '总计'
              } else if (index === 2) {
                  const values = data.map(item => Number(item[column.property]))
                  if (!values.every(value => isNaN(value))) {
                      sums[index] = values.reduce((prev, curr) => {
                          const value = Number(curr)
                          if (!isNaN(value)) {
                              return prev + curr
                          } else {
                              return prev
                          }
                      }, 0)
                      if(index === 2) {
                          sums[index] = parseFloat(sums[index]).toFixed(2)
                      }
                  } else {
                      sums[index] = ''
                  }
              } else {
                  sums[index] = '--'
              }
          })
          return sums
      },
      //自定义合计---成交
      getSummaries_cj(param) {
          const { columns, data } = param
          const sums = []
          columns.forEach((column, index) => {
              if (index === 0) {
                  sums[index] = '总计'
              } else if (index === 7 || index === 10 || index === 11) {
                  const values = data.map(item => Number(item[column.property]))
                  if (!values.every(value => isNaN(value))) {
                      sums[index] = values.reduce((prev, curr) => {
                          const value = Number(curr)
                          if (!isNaN(value)) {
                              return prev + curr
                          } else {
                              return prev
                          }
                      }, 0)
                      if(index === 10 || index === 11) {
                         sums[index] = parseFloat(sums[index]).toFixed(4)
                      }
                      if(index === 7 ) {
                          sums[index] = parseFloat(sums[index]).toFixed(0)
                      }
                  } else {
                      sums[index] = 'N/A'
                  }
              } else {
                  sums[index] = '--'
              }
          })
          return sums
      },
      //自定义合计---平仓
      getSummaries_pc(param) {
          const { columns, data } = param
          const sums = []
          columns.forEach((column, index) => {
              if (index === 0) {
                  sums[index] = '总计'
              } else if (index === 6 || index === 10) {
                  const values = data.map(item => Number(item[column.property]))
                  if (!values.every(value => isNaN(value))) {
                      sums[index] = values.reduce((prev, curr) => {
                          const value = Number(curr)
                          if (!isNaN(value)) {
                              return prev + curr
                          } else {
                              return prev
                          }
                      }, 0)
                      if(index === 6) {
                          sums[index] = parseFloat(sums[index]).toFixed(0)
                      }
                      if(index === 10) {
                          sums[index] = parseFloat(sums[index]).toFixed(4)
                      }
                  } else {
                      sums[index] = 'N/A'
                  }
              } else {
                  sums[index] = '--'
              }
          })
          return sums
      },
      //自定义合计---持仓明细
      getSummaries_cc(param) {
          const { columns, data } = param
          const sums = []
          columns.forEach((column, index) => {
              if (index === 0) {
                  sums[index] = '总计'
              } else if (index === 6 || index === 10 || index === 11 || index === 12) {
                  const values = data.map(item => Number(item[column.property]))
                  if (!values.every(value => isNaN(value))) {
                      sums[index] = values.reduce((prev, curr) => {
                          const value = Number(curr)
                          if (!isNaN(value)) {
                              return prev + curr
                          } else {
                              return prev
                          }
                      }, 0)
                      if(index === 6) {
                          sums[index] = parseFloat(sums[index]).toFixed(0)
                      }
                      if(index === 10 || index === 11) {
                          sums[index] = parseFloat(sums[index]).toFixed(4)
                      }
                      if(index === 12) {
                          sums[index] = this.statementsList_cc[0].CurrMargin
                      }
                  } else {
                      sums[index] = 'N/A'
                  }
              } else {
                  sums[index] = '--'
              }
          })
          return sums
      },
      //自定义合计---持仓汇总
      getSummaries_ccz(param) {
          const { columns, data } = param
          const sums = []
          columns.forEach((column, index) => {
              if (index === 0) {
                  sums[index] = '总计'
              } else if (index === 2 || index === 4 || index === 8 || index === 9) {
                  const values = data.map(item => Number(item[column.property]))
                  if (!values.every(value => isNaN(value))) {
                      sums[index] = values.reduce((prev, curr) => {
                          const value = Number(curr)
                          if (!isNaN(value)) {
                              return prev + curr
                          } else {
                              return prev
                          }
                      }, 0)
                      if(index === 2 || index === 4) {
                          sums[index] = parseFloat(sums[index]).toFixed(0)
                      }
                      if(index === 8) {
                          sums[index] = parseFloat(sums[index]).toFixed(4)
                      }
                      if(index === 9) {
                          sums[index] = this.statementsList_ccz[0].CurrMargin
                      }
                  } else {
                      sums[index] = 'N/A'
                  }
              } else {
                  sums[index] = '--'
              }
          })
          return sums
      },
  },
   mounted() {
     this.handle_customerChange();
    //  this.handle_realaccouncap();
    // this.handle_realtraded();
    // this.futures_getData();
  },
}
</script>